package com.du;

import com.du.bean.Boss;
import com.du.bean.Car;
import com.du.bean.Color;
import com.du.config.MainConfigAutowired;
import com.du.config.MainConfigLifeCycle;
import com.du.dao.BookDao;
import com.du.service.BookService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author djg
 * @date 2020/11/23
 * @des
 */
public class IOCTestAutowired {

    @Test
    public void test01() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigAutowired.class);

        BookService bean = applicationContext.getBean(BookService.class);
        System.out.println(bean);

//        BookDao bean1 = applicationContext.getBean(BookDao.class);
//        System.out.println(bean1);

        Boss boss = applicationContext.getBean(Boss.class);
        System.out.println(boss);
        Car car = applicationContext.getBean(Car.class);
        System.out.println(car);

        Color color = applicationContext.getBean(Color.class);
        System.out.println(color);

        System.out.println("打印的ioc容器："+applicationContext);

        applicationContext.close();

    }
}
